<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="procInsId" type="java.lang.String" required="false" description="流程实例ID"%>
<%@ attribute name="startAct" type="java.lang.String" required="false" description="开始活动节点名称"%>
<%@ attribute name="endAct" type="java.lang.String" required="false" description="结束活动节点名称"%>
<fieldset style="border:1px solid;">
	<legend>流转信息</legend>
	<div id="histoicFlowList">
		<!-- 正在加载流转信息... -->
		<table class="table" id="histoicFlowListTable">
			<tr><th>执行环节</th><th>执行人</th><th>开始时间</th><th>结束时间</th><th>意见</th><th>附件列表</th><th>任务历时</th></tr>
		</table>
	</div>
</fieldset> 
<table id="histoicFlow"></table>
<script type="text/javascript">
	$.ajax({
		type : 'POST',
		contentType : 'application/json;charset=utf-8',
		url : ctxRest + '/act/task/list-histoicFlow?t=' + new Date().getTime(),
		data : JSON.stringify({
			procInsId: getParameter('act.procInsId'),
			paramMap : {
				startAct : '',
				endAct	 : ''
			}
		}),
		success : function(result){//console.log((result));
			var html = '';
			for (var i = 0; i < result.length; i++) {
				var item = result[i];//console.log(item);
				html += '<tr>'
				html += '<td>' + item.histIns.activityName + '</td>';
				html += '<td>' + ((item.assigneeName == null) ? '' : item.assigneeName) + '</td>';
				html += '<td>' + moment(item.histIns.startTime).format('YYYY-MM-DD HH:mm:ss') + '</td>';
				html += '<td>' + ((item.histIns.endTime == null) ? '' : moment(item.histIns.endTime).format('YYYY-MM-DD HH:mm:ss')) + '</td>';
				html += '<td>' + item.comment + '</td>';
				html += '<td>';
				if (item.attachments) {
					for (var j = 0;j < item.attachments.length; j++) {
						var atta = item.attachments[j];
						if (atta.type == 'image') {
							html += '<a target="_blank" href="'+ ctxRest + "/sys/file/get?path="+ atta.url +'"><img src="' + ctxRest + "/sys/file/get?path="+ atta.url + '" style="width:100px;height:100px;" /></a><br>';
						} else {
							// TODO <a href="#">xxx附件</a>
						}
					}
				}
				html += '</td>';
				html += '<td>' + ((item.durationTime == null) ? '' : item.durationTime) + '</td>';
				html += '</tr>'
			}
			$('#histoicFlowListTable').append(html);
		}
	})
</script>